//
//  BwtAdLogManager.m
//  bwt_ad_flutter
//
//  Created by ciba on 2024/10/14.
//

#import "BwtAdLogManager.h"

@implementation BwtAdLogManager
/// 单例
+ (BwtAdLogManager *)getBwtAdLogManager {
    static BwtAdLogManager *bwtAdLogManager;
    if(!bwtAdLogManager) {
        bwtAdLogManager = [[BwtAdLogManager alloc] init];
    }
    return bwtAdLogManager;
}

- (void)log:(NSString*)message, ... {
    if (_isNeedLog) {
        // 获取当前日期和时间
        NSDate *date = [NSDate date];
        // 创建一个日期格式化器
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        // 设置格式，包括毫秒（SSS表示毫秒）
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];
        // 转换日期为字符串，包括毫秒
        NSString *dateString = [formatter stringFromDate:date];
        
        NSString *tag = @"BwtAdFlutterPlugin -> ";
        NSString *format = [NSString stringWithFormat:@"%@%@%@%@", tag, dateString, @" -> ", message];
        
        va_list args;
        va_start(args, format);
        NSLogv(format, args);
        va_end(args);
    }
}
@end
